#include "../myudp.h"

#define UDP_SERVER_IP   "192.168.31.13"
#define UDP_SERVER_PORT 50000

int main(int argc, char const *argv[])
{
    int Ret;
    int UdpServerSockFd;
    Ret = UdpSelfBind( &UdpServerSockFd, UDP_SERVER_IP, UDP_SERVER_PORT );

    char strRecvFileName[1024] = {0};
    char strClintIP[100] = {0};
    int ClintPort = 0;
    
    Ret = UdpRecvFile( UdpServerSockFd, strRecvFileName, strClintIP, &ClintPort );
    if( -1 == Ret )
    {
        perror( "fail UdpRecvFile" );
        return -1;
    }

    printf( "Received file <%s> from %s : %d\n", strRecvFileName, strClintIP, ClintPort );

    Ret = close( UdpServerSockFd );
    if( -1 == Ret )
    {
        perror( "fail close" );
        return -1;
    }

    return 0;
}
